package com.young.eventcoach.dday;

import java.util.ArrayList;

import com.young.eventcoach.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class DdayCalendarListAdapter extends ArrayAdapter<CalendarAnniversary>{
	Context context;
	ArrayList<CalendarAnniversary> arr_anniversary;
	int resId;

	public DdayCalendarListAdapter(Context context, int textViewResourceId, ArrayList<CalendarAnniversary> arr_anniversary) {
		super(context, textViewResourceId, arr_anniversary);
		this.context = context;
		this.arr_anniversary = arr_anniversary;
		this.resId = textViewResourceId;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		
		if(view == null){
			view = View.inflate(context, resId, null);
		}
		if(position==0){
			view.setBackgroundResource(R.drawable.dday_thismonth_firstday);
		}else{
			view.setBackgroundResource(R.drawable.dday_coupleday_daylist);
		}
		TextView tv_calendar_dday_name = (TextView)view.findViewById(R.id.tv_calendar_dday_name);
		TextView tv_calendar_dday_date = (TextView)view.findViewById(R.id.tv_calendar_dday_date);
		TextView tv_calendar_dday_mean = (TextView)view.findViewById(R.id.tv_calendar_dday_mean);
		
		tv_calendar_dday_name.setText(arr_anniversary.get(position).getName());
		tv_calendar_dday_date.setText("("+arr_anniversary.get(position).getDate()+")");
		tv_calendar_dday_mean.setText(arr_anniversary.get(position).getMean());
		
		return view;
	}

}
